/*
 * @Descripttion: 
 * @Author: ziwei
 * @Date: 2022-06-13 13:42:11
 * @LastEditors: ziwei
 * @LastEditTime: 2022-06-13 14:13:46
 */
//清理产出目录的插件
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
// 产出html插件
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path')
module.exports = {
    entry:'./src/index.tsx',
    output:{
        path:path.resolve(__dirname,'../dist'),//产出目录
        filename:'main.js'
    },
    resolve:{
        extensions:['.ts','.tsx','.js']
    },
    devServer:{
        static:'./dist'
    },
    module:{
        rules:[
            {
                test:/\.(j,t)sx?/,
                use:'ts-loader',
                exclude:/node_modules/
            }
        ]
    },
    plugins:[
        new CleanWebpackPlugin({
            cleanOnceBeforeBuildPatterns:['./dist']
        }),
        new HtmlWebpackPlugin({
            template:'./src/index.html'
        })
    ]
}